Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support multi ontick #932

Merged
merged 27 commits into from
May 13, 2024
Merged

Support multi ontick #932

merged 27 commits into from
May 13, 2024

Conversation

rinfx
Copy link
Collaborator

@rinfx rinfx commented May 9, 2024

支持 wasm-go-sdk 支持注册多个 ontick 函数以实现对多个定时任务的支持

插件代码示例:

func main() {
	wrapper.SetTickPeriod(1000)
	wrapper.RegisteTickFunc(1, func() { proxywasm.LogInfo("onTick 1 s") })
	wrapper.RegisteTickFunc(5, func() { proxywasm.LogInfo("onTick 5 s") })
	wrapper.RegisteTickFunc(3, func() { proxywasm.LogInfo("onTick 3 s") })
	wrapper.SetCtx(
		"hello-world",
		wrapper.ProcessRequestHeadersBy(onHttpRequestHeaders),
	)
}

wrapper.SetTickPeriodwrapper.RegisteTickFunc之间顺序无要求,wrapper.SetCtx需要在main函数最后执行

var globalOnTickFuncs []TickFuncEntry = []TickFuncEntry{}

// Registe multiple onTick functions. Parameters include:
// 1) tickPeriod: the execution period of tickFunc;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

介绍下我们默认的轮询间隔是100毫秒,tickPeriod最好设置为100毫秒的整数倍

@johnlanni johnlanni merged commit 5c77369 into alibaba:main May 13, 2024
11 checks passed
@rinfx rinfx deleted the support-multi-ontick branch November 5, 2024 01:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants